﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DXApplicationTangche.Utils;

namespace DXApplicationTangche.UC.报表.service
{
    class 用户报表service
    {
        public static DataTable get用户信息()
        {
            String sql = "select\n" +
                        "mobile, -- 电话\n" +
                        "customername, -- 客户名\n" +
                        "addressprovince, -- 省\n" +
                        "addresscity, -- 市\n" +
                        "addressdistrict, --县\n" +
                        "addressstreet, -- 街道\n" +
                        "addressdetail --详细地址\n" +
                        "from t_douyin_user_address_info\n"; ;
            DataTable dt = SQLpostgres.GetDataTable(
                sql
            );
            return dt;
        }

        public static DataTable get订单详情()
        {
            String sql = "select\n" +
                        "mobile, -- 电话\n" +
                        "suborderno, -- 子订单号\n" +
                        "unitprice, -- 单价\n" +
                        "discount, -- 折扣\n" +
                        "payable, -- 订单总金额\n" +
                        "aftersaleflg, -- 售后服务类型\n" +
                        "orderdate -- 订单详细时间\n" +
                        "from\n" +
                        "(\n" +
                        "select\n" +
                        "mobile ,\n" +
                        "suborderno ,\n" +
                        "unitprice ,\n" +
                        "discount ,\n" +
                        "payable ,\n" +
                        "case\n" +
                        "when aftersaletype = '退货退款' then 1\n" +
                        "else 0\n" +
                        "end as aftersaleflg,\n" +
                        "orderdate\n" +
                        "from\n" +
                        "v_douyin_order_with_user_info vdowui\n" +
                        "where\n" +
                        "mobile in (\n" +
                        "select\n" +
                        "mobile\n" +
                        "from\n" +
                        "v_douyin_order_with_user_info vdowui\n" +
                        "where\n" +
                        "suborderno in(\n" +
                        "select\n" +
                        "suborderno\n" +
                        "from\n" +
                        "t_douyin_order_deliver\n" +
                        "where\n" +
                        "createdate >'2022-06-18'\n" +
                        ")\n" +
                        ")\n" +
                        "and (aftersaletype <> '未发货仅退款'\n" +
                        "or aftersaletype is null)\n" +
                        ") order_summary\n"; ;
            DataTable dt = SQLpostgres.GetDataTable(
                sql
            );

            return dt;
        }
    }
}
